import Immutable from 'immutable';

const defaultState = new Immutable.List();

export default function MessageHandlerReducer(state = defaultState, action) {
  switch(action.type) {
    case 'LOAD_SUBSCRIBE_MESSAGE_HANDLER':
      var data = action.data;
      if (data.success) {
        return data.data;
      }else {
        return {};
      }
      break;
    case 'CREATE_SUBSCRIBE_MESSAGE_HANDLER':
      var data = action.data;
      if (data.success) {
        return data.data;
      }else {
        return {};
      }
      break;
    case 'ERROR_MESSAGE_HANDLER':
      return action.error.status;
    default:
      return state;
  }
}
